#include "MainScene.h"
#include "GameLayer.h"

using namespace cocos2d;

CCScene* MainScene::scene() {
	CCScene *scene = NULL;
	do {
		scene = CCScene::create();
		CC_BREAK_IF( !scene );

		MainScene *layer = MainScene::create();
		CC_BREAK_IF( !layer );

		scene->addChild(layer);
	} while (0);

	return scene;
}

bool MainScene::init() {
	bool bRet = false; 
	do {
		CC_BREAK_IF( !CCLayer::init() );

		this->setTouchEnabled(true);

		CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
		frameCache->addSpriteFramesWithFile("img.plist");

		CCSprite *gr = CCSprite::create("background.png");
		gr->setAnchorPoint(CCPointZero);
		this->addChild(gr);

		GameLayer *gameLayer = GameLayer::create();
		this->addChild(gameLayer);
		gameLayer->setAnchorPoint(CCPointZero);

		bRet = true;

	} while (0);

	return bRet;
}

void MainScene::menuCloseCallback(CCObject *pSender) {
	CCDirector::sharedDirector()->end();
}